package designPatterns.P05_适配器模式_Adapter.P01_类适配器_ClassAdapter.voltages;

import Utils.io.IOUtils;

import java.io.IOException;
import java.io.Serializable;

public abstract class Voltage implements Cloneable, Serializable {
    private Integer v;

    public Voltage() {
        init();
    }

    public Integer getV() {
        return v;
    }

    public void setV(Integer v) {
        this.v = v;
    }

    /**
     * 为v赋值
     */
    public abstract void init();

    public Integer output() {
        System.out.println("电压 = " + v + "V");
        return v;
    }

    @Override
    public Object clone() throws CloneNotSupportedException {
        try {
            return IOUtils.deepClone(this);
        } catch (IOException | ClassNotFoundException e) {
            e.printStackTrace();
            return null;
        }
    }
}
